<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:chart="http://schemas.Kherty.com/office/2007/chart"
  xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
  xmlns:drawing="http://schemas.Kherty.com/office/2007/drawing"
  xmlns:drawing2="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
  xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals"  
  x:Class="OpenLS.Chart.UI.BarSeriesResources"
    >
  <ResourceDictionary.MergedDictionaries>
    <chartui:ChartHelperResources/>
  </ResourceDictionary.MergedDictionaries>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="barNumericValueTemplate">
        <Rectangle Style="{x:Static chartui:ShapedObjectResources.ShapedElementStyle}"
               Focusable="True" Name="barRect" Internals:FormatHelper.HandlesChartCommands="True">
            <Rectangle.ToolTip>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.NumericValueToTooltipConverter}">
                    <Binding Path="Value"/>
                    <Binding Path="Index"/>
                </MultiBinding>
            </Rectangle.ToolTip>
            <chartui:ChartElement.DataPoint>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.DataPointsAccessor}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.DataPointsObserver)"/>
                    <Binding Path="Index"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.DataPointsObserver).Generation"/>
                </MultiBinding>
            </chartui:ChartElement.DataPoint>
            <drawing2:DrawingElement.ShapeProperties>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.OrSkipNullConverter}">
                    <Binding Path="(chartui:ChartElement.DataPoint).ShapeProperties" RelativeSource="{RelativeSource  Self}" />
                    <Binding Path="(chartui:SeriesElement.Series).ShapeProperties" RelativeSource="{RelativeSource Self}" />
                </MultiBinding>
            </drawing2:DrawingElement.ShapeProperties>
            <Rectangle.ContextMenu>
                <ContextMenu>
                    <MenuItem Command="{x:Static chartui:ChartCommands.UnformatDataSeries}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.AddTitle}" />
                    <MenuItem Command="{x:Static chartui:ChartCommands.AddLegend}" />
                    <MenuItem Command="{x:Static chartui:ChartCommands.AddDataLabels}" />
                    <MenuItem Command="{x:Static chartui:ChartCommands.FormatDataLabels}" />
                    <MenuItem Command="{x:Static chartui:ChartCommands.FormatDataSeries}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.FormatDataPoint}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.UnformatDataPoint}"/>
                </ContextMenu>
            </Rectangle.ContextMenu>
            <!--
            <Rectangle.BitmapEffect>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.EffectConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ColorScheme)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ShapeProperties).EffectProperties"/>
                </MultiBinding>
            </Rectangle.BitmapEffect> -->
        </Rectangle>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=(drawing2:DrawingElement.ShapeProperties).FillProperties, ElementName =barRect}" Value="{x:Null}">
                <Setter Property ="Fill" TargetName="barRect">
                    <Setter.Value>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.PatternConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.Style)"/>
                            <Binding Path="Index"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.Theme).ColorScheme"/>
                            <Binding Source="debug3"/>
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(drawing2:DrawingElement.ShapeProperties).FillProperties, ElementName =barRect}" Value="{x:Null}"/>
                    <Condition Binding="{Binding Path=(chartui:ChartElement.Chart).VaryColors, ElementName=barRect}" Value="False"/>
                </MultiDataTrigger.Conditions>
                <Setter Property ="Fill" TargetName="barRect">
                    <Setter.Value>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.PatternConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.Style)"/>
                            <Binding Path="(chartui:SeriesElement.Series).Index" RelativeSource="{RelativeSource Self}"/>
                            <Binding Path="(drawing2:DrawingElement.Theme).ColorScheme" RelativeSource="{RelativeSource Self}" />
                            <Binding Source="debug5"/>
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </MultiDataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:BarSeries}">
        <Grid chartui:SeriesElement.Series="{Binding}">

        <ItemsControl 
                    
                    chartui:ChartElement.DataPoints="{Binding DataPoints}"
                    chartui:ChartElement.DataPointsObserver="{Binding DataPoints, Converter={x:Static Internals:ChartConverters.DataPointsObserverFactory}}"
                 
                    drawing:DrawingElement.ShapeProperties="{Binding Path=ShapeProperties}"
            ItemTemplate="{StaticResource barNumericValueTemplate}">
                <ItemsControl.ItemsSource>
                    <MultiBinding Converter="{x:Static Internals:ChartConverters.NumValueThrottlingConverter}">
                        <Binding Path="Values.NumericValues"/>
                        <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}"/>
                    </MultiBinding>
                </ItemsControl.ItemsSource>
                    <ItemsControl.ItemsPanel>
          <ItemsPanelTemplate>
            <Internals:BarPanel x:Name="barPanel1"
              Orientation="{Binding Path=(chartui:ChartElement.Chart).PrimaryOrientation, RelativeSource={RelativeSource Self}}"
              chartui:ValueAxisPanel.ValueAxisOrientation="{Binding Path=(chartui:ChartElement.Chart).ValueAxis.Orientation, RelativeSource={RelativeSource Self}}"
              Internals:CategoryAxisPanel.CategoryAxisOrientation="{Binding (chartui:ChartElement.Chart).CategoryAxis.Orientation, RelativeSource={RelativeSource Self}}"
              Gap="{Binding Path=(chartui:ChartElement.Chart).GapWidth, RelativeSource={RelativeSource Self}}"
              Minimum="{Binding Path=(chartui:ChartElement.YAxisInfo).Minimum, RelativeSource={RelativeSource Self}}"
              Maximum="{Binding Path=(chartui:ChartElement.YAxisInfo).Maximum, RelativeSource={RelativeSource Self}}"
              SeriesCount ="{Binding Path=(chartui:ChartElement.Chart).Series.Count, RelativeSource={RelativeSource Self}}"
              Grouping="{Binding Path=(chartui:ChartElement.Chart).Grouping, RelativeSource={RelativeSource Self}}">
            </Internals:BarPanel>
          </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemContainerStyle>
          <Style>
            <Setter Property="chartui:SeriesElement.Value" Value="{Binding Value}"/>
            <Setter Property="chartui:SeriesElement.Index" Value="{Binding Index}"/>
                    </Style>
        </ItemsControl.ItemContainerStyle>
      </ItemsControl>

    </Grid>
  </DataTemplate>
 


</ResourceDictionary>